#pragma once
#include "DummyHandler.h"

class ConfigManager
{
	typedef std::map<uint16, SvcHandler<ConfigManager> > ServiceRegister;

public:
	enum SayMode { smNoUse = 0, smInterval, smNoInterval };

	ConfigManager(int smode = smInterval, 
		                   int sinterval = 1000, 
						   int uindex = 1) ;

	int open();
	void increase_io_count();
	void decrease_io_count();

	void add_client(DummyHandler* client);
	void remove_client(DummyHandler* client);

private:
	int say_mode_;
	int say_interval_;
	int user_start_index_;
	DWORD io_count_;
	ACE_INET_Addr connect_addr_;

	std::vector<DummyHandler*> clinet_list_;
	ServiceRegister svc_handler_;
};

typedef ACE_Singleton<ConfigManager, ACE_Null_Mutex> ConfigManagerSingleton;
#define ConfigMgr ConfigManagerSingleton::instance()

#define REGISTR_HANDLEREX(code, handler) \
	svc_handler_[code] = SvcHandler<ConfigManager>(&handler)